<%@ page import="edu.sctu.User" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018-5-8
  Time: 16:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<html>
<head>
    <title>Title</title>

    <style type="text/css">
        table{
            border-collapse: collapse;
        }

        td{
            border: 1px solid #000;
            padding: 10px;
        }
    </style>
</head>
<body>


<%



    User chen = new User();
    chen.setId(1001);
    chen.setUsername("chen");
    chen.setPassword("123456");

    List<User> userList = new ArrayList<>();
    userList.add(chen);

//    int a = 10;
    pageContext.setAttribute("chen", chen);
    pageContext.setAttribute("userList", userList);
%>

<h1>id = ${chen["id"]}</h1>
<h1>username = ${chen.username}</h1>
<h1>password = ${chen.password}</h1>


<table>
    <tr>
        <td>编号</td>
        <td>用户名</td>
        <td>密码</td>
    </tr>


    <c:forEach var="user" items="${userList}">

        <tr>
            <td>${user.id}</td>
            <td>${user.username}</td>
            <td>${user.password}</td>
        </tr>
    </c:forEach>
    <%--<%--%>
        <%--for(User user : userList){--%>
            <%--out.write("<tr><td>"+user.getId()+"</td><td>"+user.getUsername()+"</td><td>"+user.getPassword()+"</td></tr>");--%>
        <%--}--%>
    <%--%>--%>

    <%--<c:forEach var="i" begin="1" end="10">--%>
        <%--<tr><td>---: ${i}</td></tr>--%>
    <%--</c:forEach>--%>

</table>

</body>
</html>
